class Solution:
    def numberOfArithmeticSlices(self, a):
        """
        :type A: List[int]
        :rtype: int
        """
        n = len(a)
        if n == 0:
            return 0
        f = [0] * (n + 1)
        for i in range(2, n):
            if (a[i] - a[i - 1]) == (a[i - 1] - a[i - 2]):
                f[i] = f[i - 1] + 1
        total = 0
        for i in range(n + 1):
            total += f[i]
        return total

